<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background: url('images/1.jpg') no-repeat;
        }

        .baidu {
            width: 800px;
            height: 200px;
            margin: 200px auto;
        }

        .baidu li {
            float: left;
            list-style: none;
            margin: 0 2px;
        }

        .baidu li img {
            width: 190px;
        }
    </style>
</head>

<body>
    <ul class="baidu">
        <li><img src="images/1.jpg" alt=""></li>
        <li><img src="images/2.jpg" alt=""></li>
        <li><img src="images/3.jpg" alt=""></li>
        <li><img src="images/4.jpg" alt=""></li>
    </ul>
</body>
<script>
    var bgp = document.querySelector('body');
    var select = document.querySelectorAll('img');
    var address;
    for (var i = 0; i < select.length; i++) {
        select[i].onclick = function () {
            address = this.src;
            // bgp.style.background = 'url(' + address + ') no-repeat';
            document.body.style.backgroundImage = 'url(' + address + ')';
        }
    }
</script>

</html>